﻿@using WebVella.Erp.Api.Models;
@{
	var erpUser = (ErpUser)ViewBag.CurrentUser;
	var pageEditUrl = $"/sdk/objects/page/r/{ViewBag.PageId}/generated-body";
	var showSettings = false;
	if (ViewBag.PageId != null && erpUser != null && erpUser.IsAdmin)
	{
		showSettings = true;
	}
}

<!--c:UserNav_Default-->
@if (showSettings)
{
	<div class="menu-nav-wrapper settings">
		<div class="menu-nav dropdown">
			<a href="javascript:void(0)" class="pl-2 pr-2" data-navclick-handler>
				<span class="fa fa-cog icon"></span>
			</a>
		</div>
		<div class="dropdown-menu  dropdown-menu-right level-0">
			@if (erpUser != null && erpUser.IsAdmin && ViewBag.PageId != null)
			{
				<a class="dropdown-item" href="@pageEditUrl" target="_blank"><span class="fas fa-file icon fa-fw"></span>Manage Page</a>
			}
		</div>
	</div>
}


<div class="menu-nav-wrapper logout">
	<div class="menu-nav">
		<a href="/logout" class="pl-2 pr-2" title="Logout">
			<span class="fas fa-sign-out-alt"></span>
		</a>
	</div>
</div>

@*<div class="menu-nav-wrapper">
	<div class="menu-nav dropdown">
		<a href="javascript:void(0)" class="pl-2 pr-2" data-navclick-handler>
			@if (erpUser != null && !String.IsNullOrWhiteSpace(erpUser.Image))
			{
				var imagePath = erpUser.Image;
				if (!imagePath.StartsWith("/fs") && !imagePath.StartsWith("http"))
				{
					imagePath = "/fs" + imagePath;
				}
				<img class="rounded-circle avatar" src="@imagePath" />
			}
			else
			{
				<img class="rounded-circle avatar" src="/_content/WebVella.Erp.Web/assets/avatar.png" />
			}
		</a>
	</div>
	<div class="dropdown-menu  dropdown-menu-right level-0">
		<a class="dropdown-item" href="/logout">Logout</a>
	</div>
</div>*@